home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 03 Pathfinding with Astar / 01 Matthews / ase / asincludes.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-06  |  1.3 KB  |  54 lines

  1. //////////////////////////////////////////////////////////////////
  2. // Class:    CAStar class (27/6/2001)
  3. // File:    AsIncludes.h
  4. // Author:    James Matthews
  5. //
  6. // Implements the A* algorithm.
  7. // 
  8. //
  9. // Please visit http://www.generation5.org/ for the latest
  10. // in Artificial Intelligence news, interviews, articles and
  11. // discussion forums.
  12. //
  13.  
  14. #ifndef NULL
  15. #define NULL 0
  16. #endif
  17.  
  18. #define ASNL_ADDOPEN        0
  19. #define ASNL_STARTOPEN        1
  20. #define ASNL_DELETEOPEN        2
  21. #define ASNL_ADDCLOSED        3
  22.  
  23. #define ASNC_INITIALADD        0
  24. #define ASNC_OPENADD_UP        1
  25. #define ASNC_OPENADD        2
  26. #define ASNC_CLOSEDADD_UP    3
  27. #define ASNC_CLOSEDADD        4
  28. #define ASNC_NEWADD            5
  29.  
  30. class _asNode {
  31.     public:
  32.         _asNode(int a = -1,int b = -1) : x(a), y(b), number(0), numchildren(0) {
  33.             parent = next = NULL; dataptr = NULL;
  34.             memset(children, 0, sizeof(children));
  35.         }
  36.  
  37.         int            f,g,h;            // Fitness, goal, heuristic.
  38.         int            x,y;            // Coordinate position
  39.         int            numchildren;
  40.         int            number;            // x*m_iRows+y
  41.         _asNode        *parent;
  42.         _asNode        *next;            // For Open and Closed lists
  43.         _asNode        *children[8];    // Assumes square tiles
  44.         void        *dataptr;        // Associated data
  45. };
  46.  
  47. // Stack for propagation.
  48. struct _asStack {
  49.     _asNode     *data;
  50.     _asStack *next;
  51. };
  52.  
  53. typedef int(*_asFunc)(_asNode *, _asNode *, int, void *);
  54.